import React, { Component } from "react";
import { List, Toast } from "antd-mobile";
import MainLayout from "@/component/mainLayout/mainLayout";
import XHQBConfig from "@/config/XHQBConfig";
import yhTools from "@/tools/yh";
import "./index.scss";
const Item = List.Item;

class RealNameInfor extends Component {
	constructor(props) {
		super(props);
		this.state = {
			phone: "",
			allData: {}
		};
	}
	componentDidMount() {
		this.init();
	}
	init = () => {
		Toast.loading("加载中...", 100);
		let objs = {
			url: XHQBConfig.queryAuthInfo,
			params: {},
			_alertShow: false
		};
		let _that = this;
		yhTools.request(objs).then(res => {
			if (res.code === "0") {
				Toast.hide();
				_that.setState({
					allData: res.data
				});
			} else {
				Toast.info(res.message, 2);
			}
		});
	};
	render() {
		const { allData } = this.state;
		const _pageParams = {
			header: {
				title: "实名认证"
			},
			history: this.props.history,
			cacheLifecycles: this.props.cacheLifecycles
		};
		return (
			<MainLayout pageParams={_pageParams}>
				<div className="real-name-infor">
					<List className="my-list">
						<Item extra={allData.accountName}>姓名</Item>
					</List>
					<List className="my-list">
						<Item extra={"身份证"}>证件类型</Item>
					</List>
					<List className="my-list">
						<Item extra={allData.idCard}>证件号码</Item>
					</List>
					<List className="my-list">
						<Item
							arrow={allData.cardValidityStatus === "0" ? "horizontal" : ""}
							extra={
								allData.cardValidityStatus === "0" ? (
									<div style={{ color: "#f82633" }}>上传身份证</div>
								) : (
									allData.cardEndDate
								)
							}
							onClick={() =>
								allData.cardValidityStatus === "0" &&
								this.props.history.push("/xhqbauthentication")
							}
						>
							证件有效期
						</Item>
					</List>
				</div>
			</MainLayout>
		);
	}
}
export default RealNameInfor;
